using System;
using System.Collections.Generic;
using System.Text;

namespace Developex.DatabaseWrapper
{
	/// <summary>
	/// Exception occured in one of db-layer classes
	/// </summary>
	public class DatabaseException : Exception
	{
		/// <summary>
		/// Simple constructor
		/// </summary>
		/// <param name="message"></param>
		public DatabaseException(string message)
			: base(message)
		{
		}

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="message"></param>
		/// <param name="innerException"></param>
		/// <param name="path"></param>
		/// <param name="objectType"></param>
		public DatabaseException(string message, Exception innerException, string path, Type objectType)
			: base(message, innerException)
		{
			Path = path;
			ObjectType = objectType;
		}

		/// <summary>
		/// Where exception was catched
		/// </summary>
		public string Path;

		/// <summary>
		/// Type of object where exception was catched
		/// </summary>
		public Type ObjectType;

		/// <summary>
		/// Get message
		/// </summary>
		/// <returns></returns>
		public string GetMessage()
		{
			return string.IsNullOrEmpty(Message) ? InnerException.Message : Message;
		}

	}
}
